﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Easy_35_SearchInsertionLocation
{
    //搜索插入位置
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 1, 3, 5, 6 };
            Console.WriteLine(SearchInsert(nums,2));
            Console.ReadKey();
        }

        public static int SearchInsert(int[] nums, int target)
        {
            int i = 0;
            for (i = 0; i < nums.Length; i++)
            {
                if (target == nums[i])
                {
                    return i;
                }
                else if (target > nums[i])
                {
                    continue;
                }
                else
                {
                    return i;
                }
            }
            return i;
        }
    }
}
